home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-09 | 3.6 KB | 152 lines | [TEXT/MPS ] |
- --
- -- FILE: Common Objects:MediaSwitcher.k
- --
- -- AUTHOR: Dan Crow
- --
- -- DATE: 22/6/94
- --
- -- Classes and objects that are specific to the Story of Glass project
- -- For example, the named MEDIADISTRIBUTOR class
- --
- -- © 1994, 1995 Art of Memory Ltd.
- -- All Rights Reserved
- --
- -- This file is supplied as part of the TextPak demonstration. You are only
- -- entitled to use this software to understand how the demonstration works.
- -- You may not duplicate, modify, reproduce or distribute this software in
- -- any form. If you wish to purchase a licence to use this software, please
- -- contact Art of Memory Ltd.
- --
-
- -- This is an inheritable class based on the standard
- -- framework MEDIADELEGATOR class, but that can switch
- -- the media it displays.
- -- This class should probably be moved into a Common
- -- Objects library. Perhaps StoryOfGlass?
- class SwitchableMediaDelegator is MEDIADELEGATOR;
-
- has
- MediaNumber;
-
- SwitchImageOrientation(newWidth, newHeight)
- newWidth is? INTEGER;
- newHeight is? INTEGER;
-
- do
- --self.SizeTo(newWidth, newHeight);
- self.Target.SizeTo(newWidth,newHeight);
- end;
-
- SetImageLocation(newX, newY)
- newX is? INTEGER;
- newY is? INTEGER;
-
- do
- --self.MoveTo(newX, newY);
- self.target.MoveTo(newX,newY);
- end;
-
- SwitchImageMedia(imageName,...)
- imageName is? STRING;
-
- use
- myMedia;
- theMediaList;
- mediaItem;
- loopCount;
- FoundObject;
- listSize;
- oldCount;
-
- do
-
- -- Switch media to display the named image
- myMedia := self.Target;
-
- theMediaList := (MEDIA.Items @ 1).Items;
- if self.MediaNumber=VOID then
-
- -- Search through the media list for the object that
- -- holds the portrait image that we wish to switch
- from
- loopCount := 1;
- foundObject := 0;
- listSize := #theMediaList;
- until (foundObject > 0) or (loopCount > listSize) loop
- if (theMediaList @ loopCount).Target = myMedia then
- foundObject := loopCount;
- end;
- step
- loopCount := loopCount + 1;
- end;
- self.MediaNumber := foundObject;
- else
- foundObject := self.MediaNumber;
- end;
-
- if foundObject>0 then
-
- -- Set the boolean need flag on the target to false if it isn't
- -- already false.
- if myMedia.IsNeeded() then
- myMedia.UnNeed();
- end;
-
- oldCount := myMedia.PrepareCount;
- -- Force the prepare count to 0, by setting it to
- -- 1 then calling Unprepare() on it.
- if myMedia.PrepareCount>0 then
- myMedia.PrepareCount := 1;
- myMedia.UnPrepare();
- end;
-
- -- We can now guarante that self.Target.PrepareCount=0
- -- and self.Target.Needed=false and that there is no
- -- data loaded into self.Target.
-
- -- Now set the need flag on self.Target
- myMedia.Need();
-
- -- Now set the name of self.Target to point to the
- -- new file
- (theMediaList @ foundObject).Name := imageName;
-
- --if (#argument=2) then
- -- mediaItem.OverrideRoot := (argument @ 2);
- --end;
-
- -- Call Install on the media object to correctly update the name
- -- of the Target object.
- (MEDIA @ 1).Install();
-
- -- Make sure the Target object is invalidated, to force a redraw
- myMedia.InvalidateAll();
-
- -- Load the data into the target object and set PrepareCount as appropriate
- if myMedia.IsLoaded() then
- myMedia.UnLoadData();
- end;
- myMedia.LoadData();
- myMedia.Loaded := true;
- myMedia.PrepareCount := oldCount;
- end;
- end;
-
- end;
-
-
- class SwitchableMovieDelegator is SwitchableMediaDelegator;
-
- has
- SwitchImageMedia(imageName,...)
- imageName is? STRING;
-
- do
- self.SwitchableMediaDelegator:SwitchImageMedia(imageName,...);
-
- self.Target.InvalidateAll();
- self.Target.computeFocus();
- self.Target.InvalidateAll();
- end;
- end;
-